﻿Imports System.ComponentModel
Imports System.Text
Imports System.Configuration


Namespace Configuration
    ''' <summary>
    ''' 用于表示程序的设置信息
    ''' </summary>
    ''' <remarks></remarks>
    Public Class SettingInfo
        Implements INotifyPropertyChanged, ICloneable



#Region "INotifyPropertyChanged 的实现 "

        ''' <summary>
        ''' 用来引发 PropertyChanged 事件，当属性被更改之后
        ''' </summary>
        ''' <param name="propName">属性名字</param>
        Private Sub Notify(ByVal propName As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
        End Sub

        Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

#End Region
#Region "ICloneable 的实现"

        ''' <summary>
        ''' 创建当前实例的深度副本
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function Clone() As SettingInfo
            Dim newobj As New SettingInfo(Me)

            Return newobj
        End Function
        ''' <summary>
        ''' 创建当前实例的深度副本
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function ImpClone() As Object Implements System.ICloneable.Clone
            Return Clone()
        End Function

#End Region
        ''' <summary>
        ''' 创建对象新的实例
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()

            _isSkipUnicodeConversion = True
            _EncodingList = New EncodingList
            _KnowFileExtensions = New System.Configuration.CommaDelimitedStringCollection
            _NotbeOpendFileExtensions = New System.Configuration.CommaDelimitedStringCollection
            _DisabledPluginProviders = New PluginProviderIDList
            _UsePostProcessings = New PluginPostProcessingList

            _isAutoUsePostProcessings=False 
        End Sub

        ''' <summary>
        ''' 使用传递的对象创建新的实例
        ''' </summary>
        ''' <param name="info">用于获取默认值的实例对象</param>
        ''' <remarks></remarks>
        Public Sub New(info As SettingInfo)
           

            With info
                Me.isBackupSaveDocument = .isBackupSaveDocument
                Me.KnowFileExtensions = .KnowFileExtensions.Clone
                Me.NotbeOpendFileExtensions = .NotbeOpendFileExtensions.Clone
                Me.EncodingList = .EncodingList.Clone()
                Me.isUseAdvancedDestinationEncodingList = .isUseAdvancedDestinationEncodingList

                Me.isSkipUnicodeConversion = .isSkipUnicodeConversion
                Me.DisabledPluginProviders = .DisabledPluginProviders.Clone

                Me.isBatchConvertAfterAutoClose = .isBatchConvertAfterAutoClose

                Me.UsePostProcessings=.UsePostProcessings.Clone 
                Me.isAutoUsePostProcessings=.isAutoUsePostProcessings


                'TODO:增加设置成员
            End With

        End Sub



        Private _isBackupSaveDocument As Boolean
        ''' <summary>
        ''' 获取和设置一个值，用来指示在保存文档时是否备份原文件（只在从文件打开时有效）
        ''' </summary>
        ''' <value>一个布尔值</value>
        ''' <returns></returns>
        ''' <remarks>用来指示在保存文档时是否备份原文件（只在从文件打开时有效）</remarks>
        Public Property isBackupSaveDocument() As Boolean
            Get
                Return _isBackupSaveDocument
            End Get
            Set(value As Boolean)
                _isBackupSaveDocument = value
                Notify("isBackupSaveDocument")
            End Set
        End Property


        Private _KnowFileExtensions As System.Configuration.CommaDelimitedStringCollection

        ''' <summary>
        ''' 获取和设置已知文件扩展名
        ''' </summary>
        ''' <value>一个包含文件扩展名的列表</value>
        ''' <returns>字符串集合</returns>
        ''' <remarks>扩展名中以点（“.”）开头</remarks>
        Public Property KnowFileExtensions As System.Configuration.CommaDelimitedStringCollection
            Get
                Return _KnowFileExtensions
            End Get
            Set(value As System.Configuration.CommaDelimitedStringCollection)
                _KnowFileExtensions = value
                Notify("KnowFileExtensions")
            End Set
        End Property



        Private _NotbeOpendFileExtensions As System.Configuration.CommaDelimitedStringCollection


        ''' <summary>
        ''' 获取和设置不能打开的文件扩展名
        ''' </summary>
        ''' <value>扩展名的字符串</value>
        ''' <returns> 一个包含文件扩展名的列表 </returns>
        ''' <remarks>
        ''' 扩展名中以点（“.”）开头
        ''' 这个列表里的文件类型不应该打开
        ''' </remarks>
        Public Property NotbeOpendFileExtensions As System.Configuration.CommaDelimitedStringCollection

            Get
                Return _NotbeOpendFileExtensions
            End Get
            Set(value As System.Configuration.CommaDelimitedStringCollection)
                _NotbeOpendFileExtensions = value
                Notify("NotbeOpendFileExtensions")
            End Set
        End Property


        Private _EncodingList As EncodingList

        ''' <summary>
        ''' 获取和设置编码列表
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks>一个包含了已经选定Encoding列表 </remarks>
        Public Property EncodingList As EncodingList
            Get
                Return _EncodingList
            End Get
            Set(value As EncodingList)
                _EncodingList = value
                Notify("EncodingList")
            End Set
        End Property



        Private _isUseAdvancedDestinationEncodingList As Boolean

        ''' <summary>
        ''' 获取和设置一个值，指示是否使用高级输出编码列表
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks>此属性是用来指示，是否将编码列表中的内容添加到 目标列表中。并在保存的时候，可以选择编码 </remarks>
        Public Property isUseAdvancedDestinationEncodingList As Boolean
            Get
                Return _isUseAdvancedDestinationEncodingList
            End Get
            Set(value As Boolean)
                _isUseAdvancedDestinationEncodingList = value
                Notify("isUseAdvancedDestinationEncodingList")
            End Set
        End Property




        Private _isSkipUnicodeConversion As Boolean

        ''' <summary>
        ''' 获取和设置一个值，用来指示是否跳过对Unicode 编码的转换
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks> </remarks>
        Public Property isSkipUnicodeConversion As Boolean
            Get
                Return _isSkipUnicodeConversion
            End Get
            Set(value As Boolean)
                _isSkipUnicodeConversion = value
                Notify("NotifyProperty")
            End Set
        End Property



        Private _DisabledPluginProviders As PluginProviderIDList

        ''' <summary>
        ''' 获取和设置禁用插件提供器ID列表
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks> </remarks>
        Public Property DisabledPluginProviders As PluginProviderIDList
            Get
                Return _DisabledPluginProviders
            End Get
            Set(value As PluginProviderIDList)
                _DisabledPluginProviders = value
                Notify("DisabledPluginProviders")
            End Set
        End Property



        Private _isBatchConvertAfterAutoClose As Boolean

        ''' <summary>
        ''' 获取和设置一个值，用来支持在批量转换时，完成一个文档后，是否自动关闭
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks> </remarks>
        Public Property isBatchConvertAfterAutoClose As Boolean
            Get
                Return _isBatchConvertAfterAutoClose
            End Get
            Set(value As Boolean)
                _isBatchConvertAfterAutoClose = value
                Notify("isBatchConvertAfterAutoClose")
            End Set
        End Property



        Private _UsePostProcessings As PluginPostProcessingList

        ''' <summary>
        ''' 获取和设置 使用的后期处理插件
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks> </remarks>
        Public Property UsePostProcessings As PluginPostProcessingList
            Get
                Return _UsePostProcessings
            End Get
            Set(value As PluginPostProcessingList)
                _UsePostProcessings = value
                Notify("UsePostProcessings")
            End Set
        End Property


        
        Private _isAutoUsePostProcessings As Boolean

        ''' <summary>
        ''' 获取和设置
        ''' </summary>
        ''' <value> </value>
        ''' <returns> </returns>
        ''' <remarks> </remarks>
        Public Property isAutoUsePostProcessings  As Boolean
            Get
                Return _isAutoUsePostProcessings
            End Get
            Set(value As Boolean)
                _isAutoUsePostProcessings = value
                Notify("isAutoUsePostProcessings")
            End Set
        End Property


    End Class

End Namespace

